package com.scheduler.backend.po;

import com.scheduler.backend.aps.domain.deadlinefirst.OrderSlice;
import com.scheduler.backend.aps.domain.deadlinefirst.ScheduleTable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor

@Entity
@Table(name = "order_slice")
public class OrderSlicePO {

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "order_id")
    private String orderID;

    @Column(name = "product_id")
    private String productID;

    @Column(name = "craft_name")
    private String craftName;

    @Column(name = "equipment_id")
    private String equipmentID;

    @Column(name = "start_time_slot")
    private long startTimeSlot;

    @Column(name = "end_time_slot")
    private long endTimeSlot;

    public OrderSlicePO(OrderSlice orderSlice, long orderSliceSpan) {
        this.id = orderSlice.getId();
        this.orderID = orderSlice.getOrder().getOrderId();
        this.productID = orderSlice.getProduct().getProductId();
        this.craftName = orderSlice.getCraft().getCraftName();
        this.equipmentID = orderSlice.getEquipments().getResourceId();
        this.startTimeSlot = orderSlice.getStartTimeslot();
        this.endTimeSlot = this.startTimeSlot + orderSliceSpan;
    }
}
